<!--{template header}-->
<div style="width:100%; height:15px;color:#000;margin:0px 0px 10px;">
    <div style="float:left;"><a href="index.php?admin_main/stat{$setting['seo_suffix']}" target="main"><b>控制面板首页</b></a>&nbsp;&raquo;&nbsp;马甲头像生成器</div>
</div>
<!--{if isset($message)}-->
<!--{eval $type=isset($type)?$type:'correctmsg'; }-->
<table class="table">
    <tr>
        <td class="{$type}">{$message}</td>
    </tr>
</table>
<!--{/if}-->
<div style="margin-top:16px;margin-bottom:16px;background:#fff;">


</div>

<div class="alert alert-info"><b>当前剩余{$rownum}个马甲头像没生成</b></div>
<div class="row">
<div class="col col-md-12">
<div class="row">
{loop $avataruserlist $avatar}
<div class="col col-md-1" style="padding:16px;">
<a href="{url user/space/$avatar['uid']}" target="_blank"><img src="$avatar['avatar']" id="avatar{$avatar['uid']}" style="width:65px;height:65px;"/></a>
<div>{$avatar['username']}<span id="useruid{$avatar['uid']}" style="font-size:12px;color:red;display:none;">处理中...</span></div>
<div><input type="checkbox" value="{$avatar['uid']}" name="majiackbox" class="majiackbox">选择</div>
</div>
{/loop}
</div>
{if $rownum}
<input type="hidden" name="setmajianum" id="setmajianum" value="{$rownum}"/>
选择头像类别:
<select id="selectsex">
<option value="0">男</option>
<option value="1">女</option>
<option value="2">随机卡通头像</option>
<option value="3">无版权随机头像</option>
</select>
<br>
<button id="batchUpdate" type="button" class="btn btn-info" style="margin-top:16px;margin-bottom:16px;">批处理已选头像</button>
&nbsp;&nbsp;&nbsp;&nbsp;
<span><input type="checkbox" name="ckall" class="ckallmajiackbox">全选</span>
<div style="margin-top:16px;">
<p class="cktip" style="color:blue;"></p>
</div>
{/if}
</div>
</div>
<script type="text/javascript">
var _setmajiaindex=1;
function ajaxpostavatar(_uid){
	var canset=1;
	var _sex=$("#selectsex").val();
  var _url="{url admin_autocaiji/makeavatar}";
  var _data={"uid":_uid,"sex":_sex}
  function success(result){
	  if(result.code==200){
		  _setmajiaindex=1;
		  $("#avatar"+_uid).attr("src",result.src);
	    }
	  $("#useruid"+_uid).hide();
	    console.log(result);
 
  }
  $("#useruid"+_uid).show();
  $.post(_url,_data,success,"JSON",function(){$("#useruid"+_uid).hide();});
  return canset;
}
$(".ckallmajiackbox").change(function() {
	if($('.ckallmajiackbox').is(':checked')){
		console.log("选择");
		$("input[name='majiackbox']").prop("checked", $(this).is(":checked"));
	}else{
		console.log("没有选择");
		$("input[name='majiackbox']").prop("checked", $(this).is(":checked"));
	     
		
	}
	var _len=$("input[name='majiackbox']:checked").length;
	$(".cktip").html("<b>已选中"+_len+"个马甲</b>");

	});
$(".majiackbox").change(function() {
	var _len=$("input[name='majiackbox']:checked").length;
$(".cktip").html("<b>已选中"+_len+"个马甲</b>");
	});
//批量处理
$('#batchUpdate').on("click", function () {
	var _len=$("input[name='majiackbox']:checked").length;
	var _numavatar=$.trim($("#setmajianum").val());
	if(_numavatar==0){
		alert("当前没有需要生成的马甲头像");
		return false;
	}
	if(_len==0){
		alert("还没选择需要处理的头像");
return false;
	}
    var str = "";
    var _canset=1;
    $("input[name='majiackbox']:checked").each(function (index, item) {
    	
    	if(_setmajiaindex==1){
    		_canset=ajaxpostavatar($(this).val());
    	}
       console.log($(this).val());
    });
});



</script>
<!--{template footer}-->